package multi.data;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.TypedArray;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.Toast;

public class Editor extends Activity implements OnClickListener {
	Button trim, extend, editSound, addText, done;
	Bundle extras;
	String path;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.editor);

		trim = (Button) findViewById(R.id.buttonVEcrop);
		extend = (Button) findViewById(R.id.buttonVEextend);
		editSound = (Button) findViewById(R.id.buttonVEeditsound);
		addText = (Button) findViewById(R.id.buttonVEaddtext);
		done = (Button) findViewById(R.id.buttonVEdone);

		trim.setOnClickListener(this);
		extend.setOnClickListener(this);
		editSound.setOnClickListener(this);
		addText.setOnClickListener(this);
		done.setOnClickListener(this);

		extras = getIntent().getExtras();
		if (extras == null) {
			path = null;
		} else {
			path = extras.getString("path");
		}
	}

	public void onClick(View v) {
		// TODO Auto-generated method stub
		if (v == trim) {
			Toast.makeText(this, "cropped", Toast.LENGTH_LONG).show();
		} else if (v == extend) {
			Toast.makeText(this, "extended", Toast.LENGTH_LONG).show();
		} else if (v == editSound) {
			Toast.makeText(this, "sound has edited", Toast.LENGTH_LONG).show();
		} else if (v == addText) {
			Toast.makeText(this, "text has added", Toast.LENGTH_LONG).show();
		} else if (v == done) {
			Intent hasil = new Intent(getApplicationContext(), Hasil.class);
			hasil.putExtra("path", "videopath");
			startActivity(hasil);
		}
	}
	
	public class ImageAdapter extends BaseAdapter {
        int mGalleryItemBackground;
        
        public ImageAdapter(Context c) {
            mContext = c;
            // See res/values/attrs.xml for the <declare-styleable> that defines
            // Gallery1.
            TypedArray a = obtainStyledAttributes(R.styleable.Gallery1);
            mGalleryItemBackground = a.getResourceId(
                    R.styleable.Gallery1_android_galleryItemBackground, 0);
            a.recycle();
        }

        public int getCount() {
            return mImageIds.length;
        }

        public Object getItem(int position) {
            return position;
        }

        public long getItemId(int position) {
            return position;
        }

        public View getView(int position, View convertView, ViewGroup parent) {
            ImageView i = new ImageView(mContext);

            i.setImageResource(mImageIds[position]);
            i.setScaleType(ImageView.ScaleType.FIT_XY);
            i.setLayoutParams(new Gallery.LayoutParams(136, 88));
            
            // The preferred Gallery item background
            i.setBackgroundResource(mGalleryItemBackground);
            
            return i;
        }

        private Context mContext;

        private Integer[] mImageIds = {
//                R.drawable.gallery_photo_1,
//                R.drawable.gallery_photo_2,
//                R.drawable.gallery_photo_3,
//                R.drawable.gallery_photo_4,
//                R.drawable.gallery_photo_5,
//                R.drawable.gallery_photo_6,
//                R.drawable.gallery_photo_7,
//                R.drawable.gallery_photo_8
        };
    }
}